#import "CreativeWallpaperAppDelegate.h"
#import "CreativeWallpaperHomeViewController.h"
#import "SVProgressHUD.h"
// 引入JPush功能所需头文件
#import "JPUSHService.h"
// iOS10注册APNs所需头文件
#ifdef NSFoundationVersionNumber_iOS_9_x_Max
#import <UserNotifications/UserNotifications.h>
#endif
// 如果需要使用idfa功能所需要引入的头文件（可选）
#import <AdSupport/AdSupport.h>
@interface CreativeWallpaperAppDelegate ()<JPUSHRegisterDelegate>
- (void)customizeAppearance;
@end
@implementation CreativeWallpaperAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
    entity.types = JPAuthorizationOptionAlert|JPAuthorizationOptionBadge|JPAuthorizationOptionSound;
    [JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
    [JPUSHService setupWithOption:launchOptions appKey:@"49b6d11146898e301382e107"
                          channel:@"App Store"
                 apsForProduction:YES
            advertisingIdentifier:nil];
    [self customizeAppearance];
    [SupplementarypamCode_Public main_X10_Call:@"SupplementarypamCodePublic" ssw_X11_:@"SupplementarypamCodePublic"];
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    CreativeWallpaperHomeViewController *homeVC = [[CreativeWallpaperHomeViewController alloc] init];
    UINavigationController *navc = [[UINavigationController alloc] initWithRootViewController:homeVC];
    [navc.navigationBar setTintColor:[UIColor whiteColor]];
    navc.navigationBar.hidden = YES;
    self.window.rootViewController = navc;
    [self.window makeKeyAndVisible];
    return YES;
}
- (void)customizeAppearance {
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
    UIColor *applicationColor = [UIColor colorWithRed:0.47f green:0.31f blue:0.84f alpha:1.0f];
    self.window.tintColor = applicationColor;
    NSDictionary *barButtonItemTitleTextAttributes = @{ NSFontAttributeName: [UIFont semiboldApplicationFontOfSize:16.0f] };
    [[UIBarButtonItem appearance] setTitleTextAttributes:barButtonItemTitleTextAttributes forState:UIControlStateNormal];
    NSDictionary *navigationBarTitleTextAttributes = @{ NSForegroundColorAttributeName: [UIColor whiteColor],
                                                        NSFontAttributeName: [UIFont semiboldApplicationFontOfSize:19.0f] };
    [[UINavigationBar appearance] setTitleTextAttributes:navigationBarTitleTextAttributes];
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:applicationColor];
    [SVProgressHUD setFont:[UIFont semiboldApplicationFontOfSize:16.0f]];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [application setApplicationIconBadgeNumber:0];
    [JPUSHService resetBadge];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [JPUSHService registerDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    [JPUSHService handleRemoteNotification:userInfo];
    completionHandler(UIBackgroundFetchResultNewData);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    [JPUSHService handleRemoteNotification:userInfo];
}
#pragma mark < JPUSHRegisterDelegate >
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
    NSDictionary * userInfo = notification.request.content.userInfo;
    if (@available(iOS 10.0, *)) {
        if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
            [JPUSHService handleRemoteNotification:userInfo];
        }
    } else {
    }
    if (@available(iOS 10.0, *)) {
        completionHandler(UNNotificationPresentationOptionAlert);
    } else {
    }
}
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
    NSDictionary * userInfo = response.notification.request.content.userInfo;
    UNNotificationRequest *request = response.notification.request;
    UNNotificationContent *content = request.content;
    NSString *body = content.body;
    
    if (@available(iOS 10.0, *)) {
        if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
            [JPUSHService handleRemoteNotification:userInfo];
        }
    }
    completionHandler();
}
- (void)applicationWillResignActive:(UIApplication *)application {
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
}
- (void)applicationWillTerminate:(UIApplication *)application {
}
- (void)isSimpleUniversalTravelRecordsNCyFMmUejDzDLfqOcSXCYMQMS {
    NSLog(@"Get User Succrss");
}

- (void)isSimpleUniversalTravelRecordsX21QCSI9ImJGtLpobU {
    NSLog(@"Get Info Success");
}

- (void)isSimpleUniversalTravelRecordson9TgxxM3FH0jl6pKo {
    NSLog(@"Check your Network");
}

- (void)isSimpleUniversalTravelRecordsgUvdQkSK0AerkHbXl2j37cQ77C {
    NSLog(@"Check your Network");
}

- (void)isSimpleUniversalTravelRecordsG2ALIdKOtryy {
    NSLog(@"Check your Network");
}

- (void)isSimpleUniversalTravelRecords7KbHtS5mrFiT {
    NSLog(@"Get User Succrss");
}

- (void)isSimpleUniversalTravelRecordsULE4SLFekcUNQLqSAUo1A {
    NSLog(@"Check your Network");
}

- (void)isSimpleUniversalTravelRecords8zWeHxqsYtNKl4aTJsrc {
    NSLog(@"Get Info Failed");
}

- (void)isSimpleUniversalTravelRecordsXRuKgFGQoDzCXvtR03AwLz {
    NSLog(@"Get Info Failed");
}

- (void)isSimpleUniversalTravelRecordshANG2aDO7mA8 {
    NSLog(@"Get Info Success");
}

- (void)isSimpleUniversalTravelRecordsmjFcKv8w2zcOxPyPvCn {
    NSLog(@"Check your Network");
}

- (void)isSimpleCreativeWallpaperh9K7xnscJUkW9GL32RbfA4u {
    NSLog(@"Check your Network");
}

- (void)isSimpleCreativeWallpapermryqK0qd7BevNwyoTDJ8 {
    NSLog(@"Continue");
}

- (void)isSimpleCreativeWallpaperihIDgMgXDbTLk5 {
    NSLog(@"Continue");
}

- (void)isSimpleCreativeWallpaperaFe9Giu7yxq0XJkKQXgJ {
    NSLog(@"Get Info Failed");
}

- (void)isSimpleCreativeWallpaperJtKEERiBRSz8 {
    NSLog(@"Continue");
}

- (void)isSimpleCreativeWallpaperjVQ6c0PeVxxXLQaU3GHMeR8W {
    NSLog(@"Check your Network");
}

- (void)isSimpleCreativeWallpaperj0xgUDTmYlUJicVjoSSdiAgoi {
    NSLog(@"Get User Succrss");
}

- (void)isSimpleCreativeWallpaperEzcQwWlt0A4S {
    NSLog(@"Check your Network");
}

- (void)isSimpleCreativeWallpaperCV9G1AHGmjWK {
    NSLog(@"Get User Succrss");
}

- (void)isSimpleCreativeWallpapern0HrO1YBJcvsAtaD {
    NSLog(@"Check your Network");
}

- (void)isSimpleCreativeWallpaperJR9uK6C1uqdT8wKHhJ {
    NSLog(@"Get Info Failed");
}

- (void)isSimpleCreativeWallpaperpWmBLcgDuhVbdK3AAw4 {
    NSLog(@"Get Info Success");
}

- (void)isSimpleCreativeWallpaperx839VYNvl5M5K3SPUDNCmgcf3J {
    NSLog(@"Check your Network");
}

- (void)isSimpleCreativeWallpaperjuOk0VfrjP31D1f99MwW {
    NSLog(@"Get Info Failed");
}

- (void)isSimpleCreativeWallpapercuU5aaYuAerQwh {
    NSLog(@"Get User Succrss");
}

- (void)isSimpleCreativeWallpaperia4Sw0gK4aiqJvIpYqXbyN9Ge {
    NSLog(@"Get User Succrss");
}

- (void)isSimpleCreativeWallpaperJhiMDxrsRSiIFM {
    NSLog(@"Get User Succrss");
}

- (void)isSimpleCreativeWallpaperLrxAsgeIQlAkj {
    NSLog(@"Get Info Success");
}

- (void)isSimpleCreativeWallpapersDVMBz7Ur0DQ {
    NSLog(@"Get User Succrss");
}

- (void)isSimpleCreativeWallpaperJ8EhrnsEGxVxDVPv8sK {
    NSLog(@"Get Info Failed");
}

- (void)isSimpleCreativeWallpaperlRi6Lm9e6GWQwoMdC65o {
    NSLog(@"Continue");
}

- (void)isSimpleCreativeWallpaper5Ax8g0U3DhjS {
    NSLog(@"Continue");
}
@end
